﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace POVRay {
    public class Fog {
        public FogType? Type { get; set; }
        public float? Distance { get; set; }
        public Color? Color { get; set; }
        public Vector3? Turbulence { get; set; }
        public float? TurbulenceDepth { get; set; }
        public float? Omega { get; set; }
        public float? Lambda { get; set; }
        public int? Octaves { get; set; }
        public float? Offset { get; set; }
        public float? Alt { get; set; }
        public Vector3? Up { get; set; }
        public Transformation Transformation { get; set; }

        public Fog() {
        }

        public string ToString(int level) {
            StringBuilder sb = new StringBuilder();
            sb.Append("fog { ");

            if (Type.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "fog_type " + ((int)Type).POVRayString() + " ");
            }
            if (Distance.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "distance " + Distance.Value.POVRayString() + " ");
            }
            if (Color.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "color " + Color.Value.ToString() + " ");
            }
            if (Turbulence.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "turbulence " + Turbulence.Value.ToString() + " ");
            }
            if (TurbulenceDepth.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "turb_depth " + TurbulenceDepth.Value.POVRayString() + " ");
            }
            if (Omega.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "omega " + Omega.Value.POVRayString() + " ");
            }
            if (Lambda.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "lambda " + Lambda.Value.POVRayString() + " ");
            }
            if (Octaves.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "octaves " + Octaves.Value.POVRayString() + " ");
            }
            if (Offset.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "fog_offset " + Offset.Value.POVRayString() + " ");
            }
            if (Alt.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "fog_alt " + Alt.Value.POVRayString() + " ");
            }
            if (Up.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "up " + Up.Value.ToString() + " ");
            }
            if (Transformation != null) {
                sb.Append(Scene.Indentation(level + 1) + Transformation.ToString(level + 1) + " ");
            }

            sb.Append(Scene.Indentation(level) + "}");
            return sb.ToString();
        }
    }

    public enum FogType {
        Constant = 1,
        Ground = 2,
    }
}
